/**
 * 
 */
package com.geekteam.masterenglish.ui.fragment;

import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.view.View;
import android.widget.AdapterView;

import com.geekteam.masterenglish.R;
import com.geekteam.masterenglish.Adapter.AlbumAdapter;
import com.geekteam.masterenglish.provider.EEContract.Album;

/**
 * @author MTROL
 *
 */
public class ListListenFragment extends BaseListFragment{
	
	public ListListenFragment(){
		super(AlbumAdapter.TYPE_ALBUM);
	}

	@Override
	public Loader<Cursor> onCreateLoader(int type, Bundle bundle) {
		CursorLoader loader = null;
		loader = new CursorLoader(getActivity(), Album.buildAlbumInBook(getString(R.string.bookId_1)), AlbumQuerry.PROJECT, null, null, null);
		
		return loader;
	}

	@Override
	public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
		if (getActivity() == null) {
			cursor.close();
			return;
		}
		mAdapter.changeCursor(cursor);
	}

	@Override
	public void onLoaderReset(Loader<Cursor> loader) {}
	
	private interface AlbumQuerry{
		String[] PROJECT = {
				Album._ID,
				Album.ID,
				Album.TITLE,
				Album.TOTAL_LISTEN,
				Album.BOOK_ID,
				Album.COVER
		};
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Cursor cursor = (Cursor) mAdapter.getItem(position);
		
	}
}
